import java.awt.*;
import java.awt.event.*;
public class Login extends Frame{
    private TextField usernameTextField;
    private TextField passwordTextField;
    public Login() {
        setTitle("用户登录");
        setSize(300, 200);
        setLayout(new FlowLayout());
        Label usernameLabel = new Label("用户名:");
        add(usernameLabel);
        usernameTextField = new TextField(20);
        add(usernameTextField);
        Label passwordLabel = new Label("密码:");
        add(passwordLabel);
        passwordTextField = new TextField(20);
        passwordTextField.setEchoChar('*');
        add(passwordTextField);
        Button loginButton = new Button("确定");
        loginButton.addActionListener(this);
        add(loginButton);
        setVisible(true);
    }

        public static void main(String[] args) {
            Login userLogin = new Login();
        }


        public void actionPerformed(ActionEvent e) {
        String username = usernameTextField.getText();
        String password = passwordTextField.getText();

        System.out.println("用户名: " + username);
        System.out.println("密码: " + password);
    }

    }
    }
}
